package mp.weixin.WXpublic;
import java.util.Date;
public abstract class BaseReceiveMessage {

    private String toUserName;
    private String fromUserName;
    private Date createTime;

    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    public String getFromUserName() {
        return fromUserName;
    }

    public void setFromUserName(String fromUserName) {
        this.fromUserName = fromUserName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public abstract ReceiveTypeEnum getMsgType();

    public enum ReceiveTypeEnum {

        /**
         * 获取位置 这个是手动 主动的发送地理位置消息
         */
        LOCATION("获取位置", "location"),
        /**
         * 文本消息
         */
        TEXT("文本", "text"),
        /**
         * 图片消息
         */
        IMAGE("图片", "image"),
        /**
         * 语音消息
         */
        VOICE("语音", "voice"),
        /**
         * 视频消息
         */
        VIDEO("视频", "video"),
        /**
         * 小视频消息
         */
        SHORTVIDEO("小视频", "shortvideo"),
        /**
         * 链接消息
         */
        LINK("链接", "link"),
        /**
         * 事件消息
         */
        EVENT("事件", "event");
        private final String desc;
        private final String type;

        ReceiveTypeEnum(String desc, String type) {
            this.desc = desc;
            this.type = type;
        }

        public String getDesc() {
            return this.desc;
        }

        public String getType() {
            return type;
        }
        /**
         * 保证这个方法的正常使用必须保证 定义枚举对象的时候 枚举对象的名称是全大写 
         * 且 type属性转换成大写的时候 与枚举的对象名称一致
         * @param type
         * @return 
         */
        public static ReceiveTypeEnum getEnumByType(String type){
            return ReceiveTypeEnum.valueOf(type.toUpperCase());
        }
    }

    @Override
    public String toString() {
        return "BaseReceiveMessage{" + "toUserName=" + toUserName + ", fromUserName=" + fromUserName + ", createTime=" + createTime + '}';
    }

}
